package com.example.homeworkmutualevaluation.Service;

import com.example.homeworkmutualevaluation.Dao.CourseDao;
import com.example.homeworkmutualevaluation.Entity.Course;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseService {
    @Resource
    private CourseDao courseDao;
    public boolean exist(String cno) {
        return courseDao.findByCno(cno) != null;
    }
    public boolean createCourse(String cno, String cname) {
        if (exist(cno)) return false;
        else return courseDao.insert(cno, cname) > 0;
    }
    public List<Course> findAll() {
        return courseDao.findAll();
    }
    public List<Course> findAllByTphone(String tphone) {
        return courseDao.findAllByTphone(tphone);
    }
    public List<Course> findAllBySphone(String sphone) {
        return courseDao.findAllBySphone(sphone);
    }
    public boolean delete(String cno) {
        return courseDao.delete(cno) > 0;
    }
    public Course findByHomeworkid(int homeworkid) {
        return courseDao.findByHomeworkid(homeworkid);
    }
}
